@echo off

rem This batch file requires some features of COMMAND.COM in MS-DOS 5+
rem If you are using an older version, or another brand of DOS, then
rem you may need to edit this file.

echo Quick and dirty install for Undocumented DOS 2nd edition
echo.

if (%1)==() goto usage
if (%1)==(/?) goto usage
if (%1)==(-?) goto usage
set _flop=%1

if (%2)==() goto no_dir
set _targ=%2
goto do_it

:no_dir
set _targ=c:\undoc2

:do_it
echo Creating %_targ% and subdirectories
md %_targ%
if errorlevel 1 goto error_md
md %_targ%\intrlist
if errorlevel 1 goto error_md
for %%f in (1 2 3 4 5 6 7 8 9 10) do md %_targ%\chap%%f
if errorlevel 1 goto error_md
echo.

echo Copying PKUNZIP 2.0
copy %_flop%\pkunzip.exe %_targ%
if errorlevel 1 goto error_copy
echo.

echo Unzipping first-level zip (%_flop%\undoc21.zip)
%_targ%\pkunzip %_flop%\undoc21.zip %_targ%
if errorlevel 1 goto error_zip
echo.

echo DOS batch files are really lame.

echo Unzipping second-level archive zip (%_targ%\ziparch1.zip)
%_targ%\pkunzip -d %_targ%\ziparch1.zip %_targ%
if errorlevel 1 goto error_zip
del %_targ%\ziparch1.zip
echo.

echo Unzipping first-level zip (%_flop%\undoc22.zip)
%_targ%\pkunzip %_flop%\undoc22.zip %_targ%
if errorlevel 1 goto error_zip
echo.

echo I hate DOS batch files.

echo Unzipping second-level archive zip (%_targ%\ziparch2.zip)
%_targ%\pkunzip -d %_targ%\ziparch2.zip %_targ%
if errorlevel 1 goto error_zip
del %_targ%\ziparch2.zip
echo.

echo Unzipping Interrupt List
%_targ%\pkunzip %_flop%\intrlist.zip %_targ%\intrlist
if errorlevel 1 goto error_zip
echo.

echo Copying miscellaneous files
copy %_flop%\read.me %_targ% 
copy %_flop%\banner %_targ%

cls
echo.
@echo off
cls
echo.
echo DONE!
echo.
echo The Interrupt List is in %_targ%\INTRLIST -- to use, run IV.BAT. This will
echo will take a few minutes, the first time you run it, to create INTERRUP.SUM
echo for use with Bob Williamson's excellent INTERVUE program. Thereafter, IV will
echo load INTERVUE immediately.
echo.
echo Windows programs that use undocumented DOS are in %_targ%\CHAP3
echo INTRSPY (interrupt watcher) is in %_targ%\CHAP5
echo DEVLOD (load device drivers from DOS prompt) is in %_targ%\CHAP7
echo The Phantom (network redirector XMS ram disk) is in %_targ%\CHAP8
echo.
echo Thanks for purchasing the 2nd edition of Undocumented DOS!
echo See the READ.ME file to learn about a forthcoming UNDOC newsletter.
echo You might also be interested in the following Addison-Wesley books:
echo    "Undocumented Windows" by Schulman, Maxey, and Pietrek
echo    "Windows Internals" by Matt Pietrek
echo    "Windows Network Programming" by Ralph Davis
echo    "PC Interrupts" and "Network Interrupts" by Brown & Kyle (forthcoming)
echo    "DOS Internals" by Geoff Chappell (forthcoming)
echo    "The Undocumented PC" by Frank van Gilluwe (forthcoming)
echo    "Undocumented NetWare" by Tim Farley (forthcoming)
echo Available at your local bookstore, or (in the US) call 1-800-358-4566
goto end

:usage
echo usage:    INSTALL [floppy] [optional directory; default c:\undoc2]
echo example:  a:install a:
echo example:  b:install b: d:\undoc2
goto end

:error_md
echo Error: can't create directory
goto end

:error_copy
echo Error: can't copy file from floppy
goto end

:error_zip
echo Error: PKUNZIP failed; probably need more disk space.
echo Or maybe you ran INSTALL incorrectly.
echo.
goto usage

:end
set _flop=
set _targ=
echo.
